package cn.walls1717.juc.cas;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicIntegerArray;

/**
 * 原子数组测试
 *
 * @author walls1717
 * @create 2022/12/12 16:12
 **/
@Slf4j
public class AtomicIntegerArrayDemo {

    public static void main(String[] args) {
        AtomicIntegerArray atomicIntegerArray = new AtomicIntegerArray(new int[5]);

        int andSet = atomicIntegerArray.getAndSet(0, 2022);
        log.info("andSet " + andSet);
        log.info("0号下标值 " + atomicIntegerArray.get(0));

        int andIncrement = atomicIntegerArray.getAndIncrement(0);
        log.info("increment " + andIncrement);
        log.info("0号下标值 " + atomicIntegerArray.get(0));
    }
}
